package es.uclm.itsue.internet;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ItsueInternetActivity extends ListActivity {
    
	private String[] activityNames;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        activityNames = getResources().getStringArray(R.array.ActivityNames);
        setListAdapter(new ArrayAdapter<String>(
				this, 
				android.R.layout.simple_list_item_1, 
				activityNames));

        getListView().setTextFilterEnabled(true);
    }
    
    @Override
   	protected void onListItemClick(ListView l, View v, int position, long id) {
     	Log.i(getPackageName(), "Pulsado item " + position + ": \t" + activityNames[position]);
    	
     	if (activityNames[position].equals("Mostrar IP del dispositivo")) {
     		startActivity(new Intent(this,ShowIPActivity.class));
     	}
     	else if (activityNames[position].equals("Navegador web externo")) {
            startActivity(new Intent(this,BrowserIntentActivity.class));
     	}
        else if (activityNames[position].equals("Navegador web interno")) {
                startActivity(new Intent(this,BrowserViewActivity.class));
        }
     	else if (activityNames[position].equals("Sockets: cliente")) {
             startActivity(new Intent(this,SocketClientActivity.class));
     	}
     	else if (activityNames[position].equals("Sockets: servidor")) {
             startActivity(new Intent(this,SocketServerActivity.class));
     	}
     	else if (activityNames[position].equals("RESTfull APP con JSON")) {
            startActivity(new Intent(this,JSONActivity.class));
    	}
	}
}

